﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x804 上介绍了“空白页”项模板

namespace TouchPoint.Demo.Win2D
{
    using Windows.UI.Core;
    using Windows.UI.Input.Inking;
    using System.Diagnostics;
    using Microsoft.Graphics.Canvas.UI.Xaml;
    using System.Numerics;
    using Windows.UI;
    /// <summary>
    /// 可用于自身或导航至 Frame 内部的空白页。
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
            ink.InkPresenter.InputDeviceTypes = CoreInputDeviceTypes.Mouse;
            ink.InkPresenter.StrokesCollected += InkPresenter_StrokesCollected;
        }

        async private void InkPresenter_StrokesCollected(InkPresenter sender, InkStrokesCollectedEventArgs args)
        {
            InkRecognizerContainer container = new InkRecognizerContainer();
            var result = await container.RecognizeAsync(ink.InkPresenter.StrokeContainer, InkRecognitionTarget.All);
            foreach(var r in result)
            {
                foreach(var i in r.GetTextCandidates())
                {
                    Debug.WriteLine(i);
                }
            }
        }

        private void Win2d_Draw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            args.DrawingSession.DrawText("Hello Win2d", new Vector2(123, 231),Colors.Red);
        }
    }
}
